package voxietest1.jam.lunar;

import processing.core.PVector;
import voxbox.wrapper.VoxiMesh;
import voxbox.wrapper.VoxiPoint3d;

public class Ship extends VoxiMesh {
	
	private final static float GRAVITY = -0.000004f;
	
	PVector vel = new PVector();
	PVector accel = new PVector();

	public Ship(String fileName, PVector pos) {
		super(fileName, pos);
	}
	
	@Override
	public void myUpdate(){
		vel.add(accel);
		accel.z -= GRAVITY * scene.deltaTime;
		
		pos.add(vel);
		
		if(pos.z > 0.6f){
			accel.set(0, 0, 0);
			vel.mult(0);
			pos.z = 0.5f;
		} else if(pos.z < -0.6f){
			accel.set(0, 0, 0);
			vel.mult(0);
			pos.z = -0.5f;
		}
	}
	
	public void mouseClicked(){
		
		PVector thrust = heading.get();
		
		thrust.normalize();
		
		thrust.mult(-1);
		
		thrust.mult((float)(GRAVITY * 40 * scene.deltaTime));

		accel.add(thrust);
	}

}
